package net.zoneland.zrdp.framework.web.service.uniflow;


import net.zoneland.zrdp.common.core.page.Pager;
import net.zoneland.zrdp.framework.web.domain.uniflow.*;
import net.zoneland.uniflow.client.ApplyTaskPageObject;
import net.zoneland.uniflow.client.NodeObject;
import net.zoneland.uniflow.client.ProcessCurrentObject;
import net.zoneland.uniflow.client.ReadObject;
import net.zoneland.uniflow.client.ReadPageObject;
import net.zoneland.uniflow.client.ReadQueryParam;
import net.zoneland.uniflow.client.TaskDecisionObject;
import net.zoneland.uniflow.client.TaskObject;
import net.zoneland.uniflow.client.TaskPageObject;
import net.zoneland.uniflow.client.TaskQueryParam;
import net.zoneland.uniflow.client.UserInfo;

import java.util.List;
import java.util.Map;

/**
 * 统一流程接口.
 *
 * @version v1.0
 * @author YTG
 */
public interface WorkFlowService {

    /**
     * 启动流程.
     * @param startProcessParam 流程启动参数对象.
     * @return 任务列表
     **/
    List<TaskObject> startProcess(final StartProcessParam startProcessParam);

    /**
     * 复活流程到指定任务（只对已流转结束的流程有效）.
     * @author YTG
     * @param completeTaskParam 任务处理参数对象.
     * @return java.util.List<net.zoneland.uniflow.client.TaskObject>
     **/
    List<TaskObject> reliveProcessTasks(final CompleteTaskParam completeTaskParam);

    /**
     * 删除流程.
     * @author YTG
     * @param piid 流程实例ID.
     * @param applicant 当前处理人信息.
     * @param notion 审批意见.
     * @return 是否删除成功
     **/
    Boolean deleteProcess(final String piid, final UserInfo applicant, final String notion);

    /**
     * 任务处理.
     * @author YTG
     * @param completeTaskParam 任务处理参数对象.
     * @return java.util.List<net.zoneland.uniflow.client.TaskObject>
     **/
    List<TaskObject> completeTask(final CompleteTaskParam completeTaskParam);

    /**
     * 流程任务跳转.
     * @author YTG
     * @param completeTaskParam 任务处理参数对象.
     * @return java.util.List<net.zoneland.uniflow.client.TaskObject>
     **/
    List<TaskObject> nodeJump(final CompleteTaskParam completeTaskParam);

    /**
     * 待办任务跳转.
     * @author YTG
     * @param completeTaskParam 任务处理参数对象.
     * @return java.util.List<net.zoneland.uniflow.client.TaskObject>
     **/
    List<TaskObject> readyNodeJump(final CompleteTaskParam completeTaskParam);

    /**
     * 强制任务处理.
     * @author YTG
     * @param completeTaskParam 任务处理参数对象.
     * @return java.util.List<net.zoneland.uniflow.client.TaskObject>
     **/
    List<TaskObject> forceCompleteTask(final CompleteTaskParam completeTaskParam);

    /**
     * 待办,已办分页任务查询.
     * @author YTG
     * @param param 查询参数.
     * @param page 页数,从1计数.
     * @param pageSize 每页的大小.
     * @return net.zoneland.uniflow.client.TaskPageObject
     **/
    TaskPageObject queryTasksByPage(final TaskQueryParam param, final int page, final int pageSize);

    /**
     * 待办,已办分页最新任务查询.
     * @author YTG
     * @param param 查询参数.
     * @param page 页数,从1计数.
     * @param pageSize 每页的大小.
     * @return net.zoneland.uniflow.client.ApplyTaskPageObject
     **/
    ApplyTaskPageObject queryFinishedApplyTasksByPage(final TaskQueryParam param,
                                                                      final int page,
                                                                      final int pageSize);

    /**
     * 查询流程当前信息.
     * @author YTG
     * @param piid 流程编码.
     * @return net.zoneland.uniflow.client.ProcessCurrentObject
     **/
    ProcessCurrentObject queryProcessCurrentInfo(final String piid);

    /**
     * 修改工单标题.
     * @author YTG
     * @param piid 流程编码.
     * @param applyTitle 工单标题.
     * @return java.lang.Integer
     **/
    Integer setApplyTitle(final String piid, final String applyTitle);

    /**
     * 待办，已办不分页查询.
     * @author YTG
     * @param param 查询参数.
     * @return java.util.List<net.zoneland.uniflow.client.TaskObject>
     **/
    List<TaskObject> queryTasks(final TaskQueryParam param);

    /**
     * 待阅,已阅分页任务查询.
     * @author YTG
     * @param param 查询参数.
     * @param page 页数,从1计数.
     * @param pageSize 每页的大小.
     * @return net.zoneland.uniflow.client.ReadPageObject
     **/
    ReadPageObject queryReadsByPage(final ReadQueryParam param, final int page, final int pageSize);

    /**
     * 待阅、已阅不分页任务查询.
     * @author YTG
     * @param param 查询参数.
     * @return java.util.List<net.zoneland.uniflow.client.ReadObject>
     **/
    List<ReadObject> queryReads(final ReadQueryParam param);

    /**
     * 查询任务下所有决策.
     * @author YTG
     * @param systemId 系统编码.
     * @param businessProcess 流程模板编码.
     * @param node 节点编码.
     * @return java.util.List<net.zoneland.uniflow.client.TaskDecisionObject>
     **/
    List<TaskDecisionObject> queryTaskDecisions(final String systemId,
                                                                final String businessProcess,
                                                                final String node);

    /**
     * 查询运行时任务决策（决策中有判断，只查询判断结果为true）.
     * @author YTG
     * @param piid 流程编号.
     * @param nodeId 节点编码.
     * @param extendData 扩展参数.
     * @return java.util.List<net.zoneland.uniflow.client.TaskDecisionObject>
     **/
    List<TaskDecisionObject> queryTaskRuntimeDecisions(final String piid,
                                                                       final String nodeId,
                                                                       final Map<String, String> extendData);

    /**
     * 任务实例查询.
     * @author YTG
     * @param tiid 任务编码.
     * @return net.zoneland.uniflow.client.TaskObject
     **/
    TaskObject getTask(final String tiid);

    /**
     * 流程任务转交.
     * @author YTG
     * @param completeTaskParam 任务处理参数对象.
     * @return java.util.List<net.zoneland.uniflow.client.TaskObject>
     **/
    List<TaskObject> transferTask(final CompleteTaskParam completeTaskParam);

    /**
     * 查询流程模板节点.
     * @author YTG
     * @param businessProcess 流程模板编码.
     * @param priorityVer 流程模板版本号.
     * @param nodeId 节点编号.
     * @return net.zoneland.uniflow.client.NodeObject
     **/
    NodeObject queryProcessTemplateNode(final String businessProcess,
                                                        final int priorityVer,
                                                        final String nodeId);

    /**
     * 查询流程模板节点.
     * @author YTG
     * @param businessProcess 流程模板编码.
     * @param priorityVer 流程模板版本号.
     * @return java.util.List<net.zoneland.uniflow.client.NodeObject>
     **/
    List<NodeObject> queryProcessTemplateNodes(final String businessProcess, final int priorityVer);

    /**
     * 查询流程扩展参数.
     * @author YTG
     * @param piid 流程编码.
     * @param paramNames 扩展参数名称.
     * @return java.util.Map<java.lang.String,java.lang.String>
     **/
    Map<String, String> queryExtendData(final String piid, final String[] paramNames);

    /**
     * 设置流程扩展参数.
     * @author YTG
     * @param piid 流程编码.
     * @param extendData 扩展参数.
     * @return java.lang.Integer
     **/
    Integer setExtendData(final String piid, final Map<String, String> extendData);

    /**
     * 查询任务扩展数据.
     * @author YTG
     * @param tiid 任务编码.
     * @param extendParamNames 扩展参数名称.
     * @return java.util.Map<java.lang.String,java.lang.String>
     **/
    Map<String, String> queryTaskExtendData(final String tiid, final String[] extendParamNames);

    /**
     * 设置任务扩展数据.
     * @author YTG
     * @param tiid 任务编码.
     * @param extendData 扩展参数.
     * @return java.lang.Integer
     **/
    Integer setTaskExtendData(final String tiid, final Map<String, String> extendData);

    /**
     * 创建待阅.
     * @author YTG
     * @param createReadsParam 创建待阅参数对象.
     * @return java.util.List<net.zoneland.uniflow.client.ReadObject>
     **/
    List<ReadObject> createReads(final CreateReadsParam createReadsParam);

    /**
     * 获取待阅任务.
     * @author YTG
     * @param riid 任务编码.
     * @return net.zoneland.uniflow.client.ReadObject
     **/
    ReadObject getRead(final String riid);

    /**
     * 完成待阅.
     * @author YTG
     * @param riid 任务编码.
     * @param notion 审批意见.
     * @return java.lang.Integer
     **/
    Integer completeRead(final String riid, final String notion);

    /**
     * 查询任务数量.
     * @author YTG
     * @param param 任务查询参数对象.
     * @return java.lang.Integer
     **/
    Integer queryTasksCount(final TaskQueryParam param);

    /**
     * 查询待阅数量.
     * @author YTG
     * @param param 待阅查询参数对象.
     * @return java.lang.Integer
     **/
    Integer queryReadCount(final ReadQueryParam param);

    /**
     * 将任务分页结果转化成Pager格式.
     * @author YTG
     * @param taskPageObject 任务Pager对象.
     * @return Pager<TaskObjectPojo>
     **/
    Pager<TaskObjectPojo> transformTasksToPager(final TaskPageObject taskPageObject);

    /**
     * 将最新任务分页结果转化成Pager格式.
     * @author YTG
     * @param applyTaskPageObject 最新任务Pager对象.
     * @return Pager<TaskObjectPojo>
     **/
    Pager<TaskObjectPojo> transformTasksToPager(final ApplyTaskPageObject applyTaskPageObject);

    /**
     * 将待阅任务分页结果转化成Pager格式.
     * @author YTG
     * @param readPageObject 待阅Pager对象.
     * @return Pager<ReadObjectPojo>
     **/
    Pager<ReadObjectPojo> transformReadTasksToPager(final ReadPageObject readPageObject);
}
